x86/vMSI-X: Fix host crash when shutting down guests with MSI capable devices
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 18 Jul 2016 21:04:43 +0000 (22:04 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 25 Jul 2016 10:29:00 +0000 (11:29 +0100)
commitdb0eee0a071e2e3e18e79d21a9b1d6724edeeeb3
tree27d5ff73fa6d7e9d6595a21392b1ee17c6299e66
parentd933b37eb404f27557e3e8468482c8ddaeaee60e
x86/vMSI-X: Fix host crash when shutting down guests with MSI capable devices

c/s 74c6dc2d "x86/vMSI-X: defer intercept handler registration" caused MSI-X
table infrastructure not to always be initialised, but it missed one path
which needed an is-initialised check.

If a devices is passed through to a domain which is MSI capable but not MSI-X
capable, the call to msixtbl_init() is omitted, but a XEN_DOMCTL_unbind_pt_irq
hypercall still calls into msixtbl_pt_unregister().  This follows the linked
list pointer which is still NULL.

Introduce an is-initalised check to msixtbl_pt_unregister().

Furthermore, the purpose of the open-coded msixtbl_list.next check is rather
subtle.  Introduce an msixtbl_initialised() predicate instead, which makes its
purpose far more obvious.

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/hvm/vmsi.c